/*
* @Author: xiaobing00008
* @Date:   2018-10-09 11:16:38
* @Last Modified by:   xiaobing00008
* @Last Modified time: 2018-10-09 15:21:35
*/
//constants
export const ADD_GUN = '加机关枪'
export const REMOVE_GUN = '减机关枪'

//reducer
export function counter(state=0,action) {
    switch (action.type) {
        case ADD_GUN:
            return state+1
        case REMOVE_GUN:
            return state-1
        default:
            return 10
   }
}

//actionCreators
export function addGun() {
    return {type:ADD_GUN}
}

export function removeGun() {
    return {type:REMOVE_GUN}
}

//异步函数
export function addGunAsync() {
    return dispatch => {
        setTimeout(()=>{
            dispatch(addGun())
        },2000)
    }
}